<style type="text/css">@import "/templates/admin/js/dataTables/css/demo_table.css";</style>
<script type="text/javascript" src="/templates/admin/js/dataTables/js/jquery.dataTables.js"></script>
{if $TBODY_TD}

{literal}
<script type="text/javascript">
	$(document).ready(function() {
		var NowWrapTable = $('.nowraptable').dataTable( {
			"sDom":'Rlfrtip',
			"bStateSave": true,
			"aaSorting" : [],
			"aoData": [			
{/literal}
	{foreach $CFG_FIELD.aoData.bSortable as $key => $bool}
		{if $bool eq "null"}null,
		{else}{literal}{"bSortable":{/literal} {$bool} {literal}},{/literal}{/if}
	{/foreach}
{literal}
			]
		});		
	});
</script>
{/literal}

<div id="confirm">{$CONFIRM}</div>
{if $DESC_INFO}<ul class="message warning"><li>{$DESC_INFO}</li><li class="close-bt"></li></ul>{/if}
<form action="?m={$ACT_NAME}" method="post" id="pages_form_change">
<input type="hidden" name="subaction" value="updateitems" />
<table cellpadding="0" cellspacing="0" border="0" class="nowraptable">
  <thead>
    <tr> 
    {if $CFG_FIELD.edit}
    	<th>&nbsp;</th>
    {/if}
	{if $CFG_FIELD.delete}
    	<th><a href="javascript:void(0);" class="select_delete" rel="delinput_{$MODE}"><img title="удалить все записи" src="/templates/admin/img/icons/delete.png" /></a></th>
	{/if}
    {if $CFG_FIELD.por}
		<th>Порядок</th>
	{/if}       
	{foreach $CFG_FIELD.field_cfg as $k => $v}
    	<th width="{$v.width}" title="{$v.name}">{$v.name}</th>
    {/foreach}
    </tr>
  </thead>
  <tbody>
  {foreach $TBODY_TD as $tbody_item_key => $tbody_item_value}<tr>
{if $CFG_FIELD.edit}<td><a href="?m={$ACT_NAME}&type=edit&id={$tbody_item_value.id}" title="Редактировать" class="ui-helper-clearfix ui-state-default ui-corner-all"><span class="ui-icon ui-icon-pencil"></span></a></td>{/if}
{if $CFG_FIELD.delete}<td><input type="checkbox" class="delinput_{$MODE} mini-switch-delete" name="del[]" value="{$tbody_item_value.id}" /></td>{/if}
{if $CFG_FIELD.por}<td><input type="text" name="por[{$tbody_item_value.id}]" value="{$tbody_item_value.por}" size="3" class="por_input" /></td>{/if}    
{if $CFG_FIELD.field_cfg}{foreach $CFG_FIELD.field_cfg as $k => $v}<td title="{if is_array($v.fieldname)}{foreach $v.fieldname as $k_sysname => $v_sysname}{$tbody_item_value[$v_sysname]} {/foreach}{else}{$tbody_item_value[{$v.fieldname}]|strip_tags}{/if}" {$v.attr}>{if $v.link}<a href="?m={$ACT_NAME}&type=edit&id={$tbody_item_value.id}{if $IS_ACTIVE_GROUP}&active_group={$ACTIVE_GROUP_ID}{/if}">{/if}{if is_array($v.fieldname)}{foreach $v.fieldname as $k_sysname => $v_sysname}{$tbody_item_value[$v_sysname]} {/foreach}{else}{$tbody_item_value[{$v.fieldname}]|strip_tags}{/if}{if $v.link}</a>{/if}</td>{/foreach}{/if}
</tr>{/foreach}
   </tbody>  
  </table>
  <div class="clear"></div>
  <a href="javascript:void(0);" class="ui_wo_buttons change_button ui-state-default ui-corner-all"><span class="ui-icon ui-icon-refresh"></span>Изменить</a>
</form>


{elseif $Field}
<form action="" method="post" enctype="multipart/form-data" id="form_submit" class="form_submit">
  {if $smarty.get.type eq "edit"}
  	<input type="hidden" name="type" value="editt" />
    <input type="hidden" name="id" value="{$smarty.get.id}" />
  {else}
  	<input type=hidden name="type" value="add" />
  {/if}
  <div id="admin_tabs_main_content"> 
    <!-- TABS_NAME -->
    <ul>
      <li><a href="#General">Общие</a></li>
    </ul>
    <!-- END TABS_NAME --> 
    <!-- ОБЩИЕ -->
    <div id="General">
      <div style="width:730px;">
        {if $smarty.get.type eq "edit"}
          <p class="position_name">Запись создана</p>
          <p class="position_input">{$Field.date_create}<input type="hidden" name="date_create" value="{$Field.date_create}" /></p>
          
          <p class="position_name">Запись обновлена</p>
          <p class="position_input">{$Field.date_update}</p>	
        {/if}      
        <p class="position_name">Порядок</p>
        <p class="position_input"><input type="text" name="por" value="{$Field.por}" class="por-field"></p>        
        <p class="position_name">Название темплейта</p>
        <p class="position_input"><input type="text" name="name" value="{$Field.name}"></p>
        
        <p class="position_name">Название файла темплейта</p>
        <p class="position_input"><input type="text" name="tpl" value="{$Field.tpl}"></p>
      </div>
      {if !$Field.tpl_none_site}
      <p class="position_name">Код темплейта сайта</p>
      <p class="position_input"><textarea id="textarea_1" style="height:250px;" name="last_backup_site">{$Field.last_backup_site}</textarea></p>
      {/if}
      
      {if !$Field.tpl_none_admin}
      <p class="position_name">Код темплейта админ</p>
      <p class="position_input"><textarea id="textarea_2" style="height:250px;" name="last_backup_admin">{$Field.last_backup_admin}</textarea></p>
      {/if}  
    </div>
  </div>
  <div id="posbutton">
    <a href="javascript:void(0);" class="ui_wo_buttons but_save ui-state-default ui-corner-all"><span class="ui-icon ui-icon-disk"></span>Сохранить</a>
  </div>
</form>
<script type="text/javascript" src="/templates/admin/js/edit_area/edit_area_full.js"></script>
<script type="text/javascript">
$(function()
{
	$(".but_save").live("click", function(){
		$("#form_submit").attr("action", "?m=templates").submit();
	});
	{if !$Field.tpl_none_site}
	editAreaLoader.init({
		id:"textarea_1",
		start_highlight:true,
		allow_resize:"no",
		allow_toggle:true,
		language: "ru",
		syntax: "html",
		toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help",
		syntax_selection_allow: "css,html,js,php,xml",
		display: "later",
		EA_load_callback: "editAreaLoaded",
		show_line_colors: true,
		min_height: 350
	});
	{/if}
	
	{if !$Field.tpl_none_admin}
	editAreaLoader.init({
		id: "textarea_2"	
		,start_highlight: true
		,allow_resize: "no"
		,allow_toggle: true
		,language: "ru"
		,syntax: "html"
		,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
		,syntax_selection_allow: "css,html,js,php,xml"
		,display: "later"
		,EA_load_callback: "editAreaLoaded"
		,show_line_colors: true
		,min_height: 350
	});
	{/if}
});
</script>


{else}
<div id="info_table" class="ui-state-error ui-corner-all">
  <p><span class="ui-icon ui-icon-alert" style="float:left;margin-right:.3em;"></span>
  <strong>Внимание!</strong> В выбранном разделе <strong>записей нет</strong></p>
</div>
{/if}